I have found the currentDirectory()
function to get the current working directory. BUT how to set (or change) the current working directory? thsturm - Tue May 25 05:28:48 EDT 2010 |
Re: How to change the working directory?
I think there is no perm to do that. The question is, how are you facing problems with the current path? Your script should not rely on the current path, when you store a file to a stream or something you can just prepend the path: const string myPath = "C:\\My Current Dir\\" fileName = "test.txt" Stream x = read (myPath filename)
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: How to change the working directory? Mathias Mamsch - Tue May 25 06:19:23 EDT 2010
I think there is no perm to do that. The question is, how are you facing problems with the current path? Your script should not rely on the current path, when you store a file to a stream or something you can just prepend the path: const string myPath = "C:\\My Current Dir\\" fileName = "test.txt" Stream x = read (myPath filename)
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
This doesn't work if the code you are working in doesn't know what the path should be. For instance, we have an *.inc file that reads a text-based configuration file in order to get details about modules the DXL script needs to run against. Most of the ppl running this script can manage the text-based configuration file to get the data they need out of the script, but they are not versed in DXL. The inc file and the text file are a pair; so the reference to the config file is a relative path within the *.inc file. I don't control where our developers place these 2 files on their work PCs, so I can't specify an absolute path. The script can calculate where the inc file resides, but I don't want to specify an absolute path within that inc file because the user could have placed the *.inc/*.txt file pair in any directory on their PC. Is there a mechanism to specify an includes path [like you would in a makefile in programming] without forcing everyone on my entire team to change their DOORS command-line? If there is no such solution, it might also work to have the *.inc file detect its own file location (not sure if that's possible) and then infer the location of the config file from the path the *.inc file is running from.
On a side note I have found that, if you use the Load File Selector from the Edit DXL dialog box to select a DXL file from some directory (X), then relative paths from within directory X work just fine [surprisingly, even when script was a layout DXL which wasn't even running from the Edit DXL dialog). I had assumed this was because the Edit DXL Load File Selector was somehow setting the current working directory but it seems odd that a File Selector would have a capability that's not already somehow built into DXL. |
Re: How to change the working directory? KylePeters - Thu Mar 27 11:03:02 EDT 2014 This doesn't work if the code you are working in doesn't know what the path should be. For instance, we have an *.inc file that reads a text-based configuration file in order to get details about modules the DXL script needs to run against. Most of the ppl running this script can manage the text-based configuration file to get the data they need out of the script, but they are not versed in DXL. The inc file and the text file are a pair; so the reference to the config file is a relative path within the *.inc file. I don't control where our developers place these 2 files on their work PCs, so I can't specify an absolute path. The script can calculate where the inc file resides, but I don't want to specify an absolute path within that inc file because the user could have placed the *.inc/*.txt file pair in any directory on their PC. Is there a mechanism to specify an includes path [like you would in a makefile in programming] without forcing everyone on my entire team to change their DOORS command-line? If there is no such solution, it might also work to have the *.inc file detect its own file location (not sure if that's possible) and then infer the location of the config file from the path the *.inc file is running from.
On a side note I have found that, if you use the Load File Selector from the Edit DXL dialog box to select a DXL file from some directory (X), then relative paths from within directory X work just fine [surprisingly, even when script was a layout DXL which wasn't even running from the Edit DXL dialog). I had assumed this was because the Edit DXL Load File Selector was somehow setting the current working directory but it seems odd that a File Selector would have a capability that's not already somehow built into DXL. This response may not actually help. I asked Telelogic if an included include file could directly determine it's full path; but it could not. However, although I never got around to it, you could do this
Before the explicit "addins" variable paths are searched, DOORS will automatically search these first (I think, need verification)
So:
Then you would look for that Windows file, in a loop, here; stopping when found:
In your case you are looking for the data file. Here is my function to see if a windows file actually exists; not sure it is "perfect".
-Louie Having said all that, I did manage to somehow change the "currentDirectory" of the client PC when running DOORS on CITRIX, the client PC user would open Windows and navigate to some directory. This was the only time the "currentDirectory" was not also the "InstallDirectory" that I found. Never figured it out exactly, nor how to do it with a normal DOORS client. |